// miniprogram/devTools/wanandroid/article/detail/detail.js
Page({

  data: {
    contents: [],
    title: '',
    url: ''
  },
  onLoad(options) {
    let url = options.url
    let title = options.title
    if (!url) return
    wx.cloud.callFunction({
      name: 'wanandroid',
      data: {
        action: "getHtmlData",
        url: url
      }
    }).then(res => {
      console.log(res)
      let contents = res.result.content
      this.setData({
        contents,
        title,
        url
      })
    })
    wx.setNavigationBarTitle({
      title: title
    })
  },
  onShareAppMessage() {

  },
  // 复制文字监听
  copyText: function (e) {
    // console.log(e)
    let text = e.currentTarget.dataset.text
    console.log("copyText", text)
    wx.setClipboardData({
      data: text,
      success: function (res) {
        wx.getClipboardData({
          success: function (res) {
            wx.showToast({
              title: '复制成功',
              icon: 'none'
            })
          }
        })
      }
    })
  },
})